package com.joysuch.wwyt.edu.enums;

/**
 * 培训合格标准
 */
public enum TrainingQualifiedStandard {

    FINISH_SIGN_IN(0, "完成签到"),
    MANUAL_ENTRY(1, "手动录入"),
    PASS_EXAM(2, "考试通过"),
    FINISH_COURSE(3, "学完课程"),
    FINISH_COURSE_EXAM(4, "学完课程+考试通过"),
    FINISH_SIGN_IN_EXAM(5, "完成签到+考试通过");

    private int id;
    private String name;

    TrainingQualifiedStandard(int id, String name) {
        this.id = id;
        this.name = name;
    }

    public int getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public static TrainingQualifiedStandard findByName(String name) {
        TrainingQualifiedStandard[] values = TrainingQualifiedStandard.values();
        for (TrainingQualifiedStandard v : values) {
            if (v.getName().equals(name)) {
                return v;
            }
        }
        return null;
    }

    public static TrainingQualifiedStandard findById(Integer level) {
        TrainingQualifiedStandard[] values = TrainingQualifiedStandard.values();
        for (TrainingQualifiedStandard v : values) {
            if (v.getId() == level) {
                return v;
            }
        }
        return null;
    }

    public static String findNameById(Integer id) {
        if (id == null) {
            return null;
        }
        TrainingQualifiedStandard[] values = TrainingQualifiedStandard.values();
        for (TrainingQualifiedStandard v : values) {
            if (v.getId() == id) {
                return v.getName();
            }
        }
        return null;
    }
}
